<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改学生信息')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-stu-edit" th:object="${stu}">
			<input name="stuId"  type="hidden"  th:field="*{stuId}" />
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">辅导员：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuInstructor" required th:field="*{stuInstructor}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">姓名：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuName" id="stuName" required th:field="*{stuName}">
						</div>
					</div>
				</div>
			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">曾用名：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="stuPastName" name="stuPastName" th:field="*{stuPastName}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">性别：</label>
						<div class="col-sm-8">
							<select name="stuSex" class="form-control m-b">
								<option   th:value="男" th:field="*{stuSex}"> 男</option>
								<option   th:value="女" th:field="*{stuSex}"> 女</option>
							</select>
						</div>
					</div>
				</div>

			</div>





			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">出生日期：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="stuBirth" name="stuBirth" autocomplete="off" th:value="${#dates.format(stu.stuBirth, 'yyyy-MM-dd')}" >
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">身份证：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuIdCard"  id="stuIdCard" required th:field="*{stuIdCard}">
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">籍贯：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuProvince" required th:field="*{stuProvince}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">国籍：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuCountry" required th:field="*{stuCountry}">
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">民族：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuNation" required th:field="*{stuNation}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">婚姻：</label>
						<div class="col-sm-8">
							<select name="stuMarriage" class="form-control m-b">
								<option   th:value="已婚" th:field="*{stuMarriage}"> 已婚</option>
								<option   th:value="未婚" th:field="*{stuMarriage}"> 未婚</option>
								<option   th:value="离异" th:field="*{stuMarriage}"> 离异</option>
							</select>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">家庭住址：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuAddress" required th:field="*{stuAddress}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">邮政编码：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuPostalCode" required th:field="*{stuPostalCode}">
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">政治面貌：</label>
						<div class="col-sm-8">
							<select name="stuPoliticalOutlook" class="form-control m-b">
								<option   th:value="共产党员" th:field="*{stuPoliticalOutlook}"> 共产党员</option>
								<option   th:value="预备党员" th:field="*{stuPoliticalOutlook}"> 预备党员</option>
								<option   th:value="共青团员" th:field="*{stuPoliticalOutlook}"> 共青团员</option>
								<option   th:value="群众" th:field="*{stuPoliticalOutlook}"> 群众</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">二级学院：</label>
						<div class="col-sm-8">
							<select name="stuCollege" class="form-control m-b">
								<option   th:value="商学院" th:field="*{stuCollege}"> 商学院</option>
								<option   th:value="现代管理学院" th:field="*{stuCollege}"> 现代管理学院</option>
								<option   th:value="土木工程学院" th:field="*{stuCollege}"> 土木工程学院</option>
								<option   th:value="人工智能学院" th:field="*{stuCollege}"> 人工智能学院</option>
								<option   th:value="外国语与海外教育学院" th:field="*{stuCollege}"> 外国语与海外教育学院</option>
								<option   th:value="设计学院" th:field="*{stuCollege}"> 设计学院</option>
								<option   th:value="儿童发展教育学院" th:field="*{stuCollege}"> 儿童发展教育学院</option>
								<option   th:value="现代音乐学院" th:field="*{stuCollege}"> 现代音乐学院</option>
								<option   th:value="法学院" th:field="*{stuCollege}"> 法学院</option>
							</select>
						</div>
					</div>
				</div>

			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">专业：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuMajor" required th:field="*{stuMajor}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">年级：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuGrade" required th:field="*{stuGrade}">
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">班级：</label>
						<div class="col-sm-8">
							<select name="stuClass" class="form-control m-b">
								<option   th:value="1班" th:field="*{stuClass}">1班</option>
								<option   th:value="2班" th:field="*{stuClass}">2班</option>
								<option   th:value="3班" th:field="*{stuClass}">3班</option>
								<option   th:value="4班" th:field="*{stuClass}">4班</option>
								<option   th:value="5班" th:field="*{stuClass}">5班</option>
								<option   th:value="6班" th:field="*{stuClass}">6班</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学籍状态：</label>
						<div class="col-sm-8">
							<select name="stuStates" class="form-control m-b">
								<option   th:value="在学" th:field="*{stuStates}">在学</option>
								<option   th:value="休学" th:field="*{stuStates}">休学</option>
								<option   th:value="保留学籍" th:field="*{stuStates}">保留学籍</option>
								<option   th:value="退学" th:field="*{stuStates}">退学</option>
								<option   th:value="毕业" th:field="*{stuStates}">毕业</option>
								<option   th:value="结业" th:field="*{stuStates}">结业</option>
								<option   th:value="其他" th:field="*{stuStates}">其他</option>
							</select>
						</div>
					</div>
				</div>

			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学制：</label>
						<div class="col-sm-8">
							<select name="stuLength" class="form-control m-b">
								<option   th:value="两年制" th:field="*{stuLength}">两年制</option>
								<option   th:value="四年制" th:field="*{stuLength}">四年制</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">培养层次：</label>
						<div class="col-sm-8">
							<select name="stuLevel" class="form-control m-b">
								<option   th:value="硕士研究生" th:field="*{stuLevel}">硕士研究生</option>
								<option   th:value="本科" th:field="*{stuLevel}">本科</option>
								<option   th:value="专升本" th:field="*{stuLevel}">专升本</option>
								<option   th:value="自考本科" th:field="*{stuLevel}">自考本科</option>
								<option   th:value="培训生" th:field="*{stuLevel}">培训生</option>
							</select>
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">学生类别：</label>
						<div class="col-sm-8">
							<select name="stuType" class="form-control m-b">
								<option   th:value="硕士研究生" th:field="*{stuType}">硕士研究生</option>
								<option   th:value="本科" th:field="*{stuType}">本科</option>
								<option   th:value="专升本" th:field="*{stuType}">专升本</option>
								<option   th:value="自考本科" th:field="*{stuType}">自考本科</option>
								<option   th:value="培训生" th:field="*{stuType}">培训生</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">入学时间：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuEnterTime" id="stuEnterTime" autocomplete="off" required  th:value="${#dates.format(stu.stuEnterTime, 'yyyy-MM-dd')}" >
						</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">生源地：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuSource" required th:field="*{stuSource}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">考生号：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="stuExamNum" required th:field="*{stuExamNum}">
						</div>
					</div>
				</div>

			</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">图片地址：</label>
						<div class="row">
							<div class="col-sm-6 col-md-3" style="width:38%!important;">
								<div class="thumbnail" style="line-height: 118px;display: flex;flex-direction: row">
									<input id="image" name="stuImg" class="form-control" th:field="*{stuImg}" type="text"  style="display:none"  />
									<img name="image" th:src="*{stuImg}"
										 id="product" alt="头像" style="width: 100%;height: 400px" onclick="avatar()">
								</div>
							</div>

						</div>
					</div>
				</div>

			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var prefix = ctx + "common/man";
	
		$("#form-stu-edit").validate({
			rules:{
                stuIdCard:{
                    isIdCardNo:true,
                },
                stuNation:{
                    isStuNation:true,
				},
                stuMarriage:{
                    isStuMarriage:true,
				},
                stuPoliticalOutlook:{
                    isStuPoliticalOutlook:true,
				},
                stuPostalCode:{
                    isStuPostalCode:true,
				},
				stuExamNum:{
                	isStuExamNum:true,
				}
			},
			focusCleanup: true
		});
        /*用户上传头像*/
        function avatar() {
            var url = prefix + '/avatar';
            $.modal.open("头像上传", url);
        }
        $(function () {
            if([[${stu.stuImg}]]==null||[[${stu.stuImg}]]=="")
            {
                $("#product")[0].src=ctx + 'img/pitera.png'
            }

        })
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-stu-edit').serialize());
	        }
	    }
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#stuEnterTime',
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {

                }
            });
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#stuBirth',
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {

                }
            });
        });

        $(function() {
            jQuery.validator.addMethod("isIdCardNo", function (value, element){
                return this.optional(element) || isIdCardNo(value);
            },"请正确输入您的身份证号码");
            jQuery.validator.addMethod("isStuNation", function (value, element){
                return this.optional(element) || minzu(value);
            },"请正确输入正确的民族");
            jQuery.validator.addMethod("isStuMarriage", function (value, element){
                return this.optional(element) || hunyin(value);
            },"请正确输入已婚或未婚");
            jQuery.validator.addMethod("isStuPoliticalOutlook", function (value, element){
                return this.optional(element) || zhengzhi(value);
            },"请正确输入正确的政治面貌");
            jQuery.validator.addMethod("isStuPostalCode", function (value, element){
				return this.optional(element) || youzheng(value);
			},"请正确输入邮政编码");
			jQuery.validator.addMethod("isStuExamNum", function (value, element){
				return this.optional(element) || kaoshenghao(value);
			},"请正确输入考生号");
            function isIdCardNo(num) {
                var factorArr = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5,8, 4, 2, 1];
                var parityBit = ["1", "0", "X", "9", "8", "7", "6", "5", "4","3", "2"];
                var varArray= [];
                var lngProduct = 0;
                var intCheckDigit;
                var intStrLen = num.length;
                var idNumber= num;
                //initialize
                if(intStrLen !== 18) {
                    return false;
                }
                // check andset value
                for (i = 0;i < intStrLen; i++) {
                    varArray[i] = idNumber.charAt(i);
                    if ((varArray[i] < '0' || varArray[i]> '9') && (i !== 17)){
                        return false;
                    } else if (i < 17) {
                        varArray[i] = varArray[i] * factorArr[i];
                    }
                }

                if(intStrLen === 18) {
                    //check date
                    var date8 = idNumber.substring(6, 14);
                    if (!isDate8(date8)) {
                        return false;
                    }
                    // calculate the sum of the products
                    for (i = 0; i < 17; i++) {
                        lngProduct = lngProduct + varArray[i];
                    }
                    // calculate the check digit
                    intCheckDigit = parityBit[lngProduct % 11];
                    // check last digit
                    if (varArray[17] != intCheckDigit) {
                        return false;
                    }
                }else{
                    return false;
                }
                return true;
            }



            function isDate8(sDate) {
                if(!/^[0-9]{8}$/.test(sDate)) {
                    return false;
                }
                var year,month, day;
                year =sDate.substring(0, 4);
                month =sDate.substring(4, 6);
                day =sDate.substring(6, 8);
                var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31];
                if (year< 1700 || year > 2500) {
                    return false;
                }
                if (((year %4 == 0) && (year % 100 != 0)) ||(year % 400 == 0)) {
                    iaMonthDays[1] = 29;
                }
                if (month< 1 || month > 12) {
                    return false;
                }
                return !(day < 1 || day > iaMonthDays[month - 1]);
            }


            function  minzu(value) {
				var min="汉族、蒙古族、回族、藏族、维吾尔族、苗族、彝族、壮族、布依族、朝鲜族、满族、侗族、瑶族、白族、土家族、哈尼族、哈萨克族、傣族、黎族、僳僳族、佤族、畲族、高山族、拉祜族、水族、东乡族、纳西族、景颇族、柯尔克孜族、土族、达斡尔族；\n" +
                    "\n" +
                    "仫佬族、羌族、布朗族、撒拉族、毛南族、仡佬族、锡伯族、阿昌族、普米族、塔吉克族、怒族、乌孜别克族、俄罗斯族、鄂温克族、德昂族、保安族、裕固族、京族、塔塔尔族、独龙族、鄂伦春族、赫哲族、门巴族、珞巴族、基诺族"
                var zu=min.split("、");
                for (var i = 0; i <zu.length ; i++) {
					if(value==zu[i])
					{
					    return true
					}
                }
                return false
            }
            function hunyin(value) {
				if(value=="已婚"||value=="未婚")
				{
				    return true
				}
				return false
            }
            function zhengzhi(value) {
				if(value=="群众"||value=="中共党员"||value=="共青团员"||value=="预备党员")
				{
                    return true
				}
                return false
            }
            function youzheng(value) {
                var re = /^[1-9][0-9]{5}$/
                if(re.test(value))
				{
                    return true
				}
                return false
            }
            function kaoshenghao(value) {
				var ksh = /^[1-9][0-9]{13}$/
				if(ksh.test(value))
				{
					return true
				}
				return false
			}
        })
	</script>
</body>
</html>
